{% load i18n %}

{% if app_list %}
    {% for app in app_list %}
        <div class="app-{{ app.app_label }} module{% if app.app_url in request.path %} current-app{% endif %}">
            <div class="bg-base-50 mb-6 rounded-default p-3 dark:bg-base-800">
                <table class="border border-base-400/10 border-spacing-none border-separate rounded-default overflow-hidden shadow-xs w-full dark:border-base-800">
                    <caption class="font-semibold mb-3 text-base-900 text-left dark:text-base-100">
                        <a href="{{ app.app_url }}" class="section" title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}">
                            {{ app.name }}
                        </a>
                    </caption>

                    {% for model in app.models %}
                        <tr class="bg-white dark:bg-base-900 model-{{ model.object_name|lower }}{% if model.admin_url in request.path %} current-model{% endif %}">
                            {% if model.admin_url %}
                                <th scope="row" class="font-normal p-3 text-left {% if not forloop.last %}border-b border-base-100 dark:border-base-800{% endif %}">
                                    <a href="{{ model.admin_url }}"{% if model.admin_url in request.path %} aria-current="page"{% endif %}>
                                        {{ model.name }}
                                    </a>
                                </th>
                            {% else %}
                                <th scope="row" class="font-normal p-3 text-left {% if not forloop.last %}border-b border-base-100 dark:border-base-800{% endif %}">
                                    {{ model.name }}
                                </th>
                            {% endif %}

                            <td class="{% if not forloop.last %}border-b border-base-100 dark:border-base-800{% endif %} p-3 text-right">
                                <div class="flex flex-row items-center ml-auto gap-4 justify-end">
                                    {% if model.add_url %}
                                        <a href="{{ model.add_url }}" class="addlink block leading-none text-base-400 transition-colors dark:text-base-500 " title="{% translate 'Add' %}">
                                            <span class="material-symbols-outlined">add</span>
                                        </a>
                                    {% endif %}

                                    {% if model.admin_url and show_changelinks %}
                                        {% if model.view_only %}
                                            <a href="{{ model.admin_url }}" class="viewlink block leading-none text-base-400 transition-colors dark:text-base-500" title="{% translate 'View' %} ">
                                                <span class="material-symbols-outlined">visibility</span>
                                            </a>
                                        {% else %}
                                            <a href="{{ model.admin_url }}" class="changelink block leading-none text-base-400 transition-colors dark:text-base-300" title="{% translate 'Change' %}">
                                                <span class="material-symbols-outlined">edit_square</span>
                                            </a>
                                        {% endif %}
                                    {% elif show_changelinks %}
                                    {% endif %}
                                </div>
                            </td>

                        </tr>
                    {% endfor %}
                </table>
            </div>
        </div>
    {% endfor %}
{% else %}
    <p>
        {% trans "You don’t have permission to view or edit anything." as error_message %}
        {% include "unfold/helpers/messages/error.html" with error=error_message %}
    </p>
{% endif %}
